﻿namespace WebSilverlight
{
    using System.Windows.Controls;
    using System.Windows.Navigation;
    using WebSilverlight.Web;
    using System.ServiceModel.DomainServices.Client;
    using WebSilverlight.Controls;
    public enum GenderEnum { Hombre = 1, Mujer = 2 };
    /// <summary>
    /// Home page for the application.
    /// </summary>
    public partial class Home : Page
    {
        /// <summary>
        /// Creates a new <see cref="Home"/> instance.
        /// </summary>
        public Home()
        {
            InitializeComponent();

            this.Title = ApplicationStrings.HomePageTitle;


            /*
<HyperlinkButton x:Name="LinkClienteWorkWith" Style="{StaticResource DK_DashboardLinkStyle}" NavigateUri="/ClienteWorkWith" TargetName="ContentFrame" >
    <StackPanel Orientation="Horizontal">
        <Image x:Name="ClienteImage" Source="/WebSilverlight;component/Resources/community-users-icon.png" Margin="5,5,5,5"/>
        <TextBlock x:Name="ClienteLabel" Text="Clientes" VerticalAlignment="Center"/>
    </StackPanel>
</HyperlinkButton>
             */
            /*
            TextBlock customTxt = new TextBlock();
            customTxt.Text = "CUSTOM URL";

            HyperlinkButton customhl = new HyperlinkButton();
            customhl.Name = "CustomLink";            
            customhl.NavigateUri = new System.Uri("/ClienteWorkWith");
            customhl.TargetName = "ContentFrame";
            customhl.Content = customTxt;

            LinksStackPanel.Children.Add(customhl);*/
        }

        /// <summary>
        /// Executes when the user navigates to this page.
        /// </summary>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void button1_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            
            ClienteDomainContext dcClienteContext1 = new ClienteDomainContext();
            EntityQuery<ClienteWrapper> ce = dcClienteContext1.GetClienteQuery();
            dcClienteContext1.Load<ClienteWrapper>(ce);
            ClienteWrapper wrap = null;
            for (short i = 1; i < 10000; i++ )
            {
                wrap = new ClienteWrapper();
                short age = (short)(i % 10);
                age += 20;               
                
                wrap.ClienteAge = age;
                wrap.ClienteBirthday = new System.DateTime(2010 - age, 4, 19);

                wrap.ClienteGender = 2;//(short)DeklaritModel.GenderEnum.Mujer;
                if (i % 2 == 0) wrap.ClienteGender = 1;//(short)DeklaritModel.GenderEnum.Hombre;

                wrap.ClienteIsActive = true;
                string nbr = i+"";
                nbr = nbr.PadLeft(5, '0');
                wrap.ClienteName = "DV" + nbr;

                dcClienteContext1.ClienteWrappers.Add(wrap);
            }
            dcClienteContext1.SubmitChanges();   
            
        }
    }
}